
#include "CLVarNode.h"

CLVarNode::CLVarNode(Box* pBox,string value)
:m_pBox( pBox )
{
	m_value=value;//this->m_pBox->charValue(value);
}

CLVarNode::~CLVarNode(void)
{
}

bool CLVarNode::valueB(int FCNo)
{
	//std::cout<<"\t?? LDVN::val "<<this->m_value<<" "<<this->m_pBox->charValue(this->m_value[0],FCNo)<<std::endl;
	double attr=this->m_pBox->charValue(this->m_value[0], FCNo);
	//char c_nrChck=this->m_value.substr(3);
	int nrChck;// = static_cast<int>(this->m_value.substr(2));

	std::istringstream sValue;
	sValue.str(this->m_value.substr(2));
	//string value=inLine.substr(0,found);
	//int iValue;//=std::atof(value);
	sValue >> nrChck;
	int charPos=this->m_pBox->charPos(this->m_value[0]);
	//std::cout<<"\t?? LDVN:vB: cpos:"<<charPos<<" nr:"<<nrChck<<std::endl;
	double value=this->m_pBox->checkedValue(charPos,nrChck);
	char rel=this->m_value[1];
	bool retVal;
	//std::cout<<"\t?? LDVN:vB: attr:"<<attr<<" val:"<<value;
	switch (rel){
		case '<':
			retVal= attr<value;
			break;
		case '>':
			retVal= attr>value;
			break;
		case '=':
			retVal= attr==value;
			break;
		case '!':
			retVal= attr!=value;
			break;
	}
	/*if(retVal){
		std::cout<<" T"<<std::endl;
	}
	else{
		std::cout<<" F"<<std::endl;
	}*/
	return retVal;
}

bool CLVarNode::addNode(const char* c)
{
 
	return false;
}

void CLVarNode::print()
{
	std::cout<<this->m_value;
}

void CLVarNode::printValue()
{
	std::cout<<this->m_value;
}

bool CLVarNode::hasPlace()
{
	return false;
}